package VNFmeetsVON_MRDP_small;

import java.io.File;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;

import test.Posong;
import cern.colt.matrix.tdouble.DoubleFactory1D;
import cern.colt.matrix.tdouble.DoubleMatrix1D;
import cern.jet.random.tdouble.Exponential;

import com.net2plan.interfaces.networkDesign.Demand;
import com.net2plan.interfaces.networkDesign.Link;
import com.net2plan.interfaces.networkDesign.Net2PlanException;
import com.net2plan.interfaces.networkDesign.NetPlan;
import com.net2plan.interfaces.networkDesign.NetworkLayer;
import com.net2plan.interfaces.networkDesign.Node;
import com.net2plan.interfaces.networkDesign.SharedRiskGroup;
import com.net2plan.interfaces.simulation.IEventGenerator;
import com.net2plan.interfaces.simulation.SimEvent;
import com.net2plan.libraries.SRGUtils;
import com.net2plan.libraries.TrafficMatrixGenerationModels;
import com.net2plan.libraries.WDMUtils;
import com.net2plan.utils.InputParameter;
import com.net2plan.utils.Pair;
import com.net2plan.utils.RandomUtils;
import com.net2plan.utils.Triple;

public class Test_Gen_nfv extends IEventGenerator {

	/* ********************************************** */
	private static int numberofallrequests = 1000 ;
	/* ********************************************** */
	
	private final static String DATE_FORMAT = "MM/dd/YY HH:mm:ss";
	
	@Override
	public String getDescription() {
		return "OK";
	}

	@Override
	public List<Triple<String, String, String>> getParameters() {
		return InputParameter.getInformationAllInputParameterFieldsOfObject(this);
	}

	@Override
	public void initialize(NetPlan initialNetPlan, Map<String, String> algorithmParameters, Map<String, String> simulationParameters, Map<String, String> net2planParameters) {
		
		/* Initialize all InputParameter objects defined in this object (this uses Java reflection) */
		InputParameter.initializeAllInputParameterFieldsOfObject(this, algorithmParameters);
		
		
      
     

		
		for(int a=0;a<numberofallrequests;a++) {
			
			NetPlan VNFnetplan_1 = CreateNetplan.createOneNetplan();
			
//			System.out.println("Number "+a+VNFnetplan_1);
			scheduleEvent(new SimEvent(a+Math.random(), SimEvent.DestinationModule.EVENT_GENERATOR , -1 , new VNFDeployment(VNFnetplan_1)));
			
		}
		
		
	}

	
	
	
	@Override
	public void processEvent(NetPlan currentNetPlan, SimEvent event) {
		
		final double simTime = event.getEventTime();
		Object eventObject = event.getEventObject();
		
		if (eventObject instanceof VNFDeployment)
		{

			final VNFDeployment vnfDeployment = (VNFDeployment) eventObject;
			final NetPlan netplan = vnfDeployment.netplan;
			

			scheduleEvent(new SimEvent (simTime, SimEvent.DestinationModule.EVENT_PROCESSOR , 200 , netplan));	
			

		
		}
	}
	
	
	private static class VNFDeployment{
		
		public final NetPlan netplan;
		
		public VNFDeployment(NetPlan netplan){
			this.netplan = netplan;
		}
		
		public String toString() {
			return "Generate connection request for demand ";
		}
	}
	
	

}
